using System;
using System.Collections.Generic;
using System.Text;

using phorm.database.core;

namespace phorm.model.fields
{
    /// <summary>
    /// A SQL date/time column used for storing the time of last modification of a column
    /// </summary>
    public class LastModifiedSQLDateTime : SQLDateTime, IAutoUpdateColumn
    {
        /// <summary>
        /// Constructor of this object uses base constructor.
        /// </summary>
        /// <param name="obj">The model object to which this column belongs</param>
        public LastModifiedSQLDateTime(DatabaseRecord obj)
            : base(obj)
        {
        }

        /// <summary>
        /// Definition of update method required by IAutoUpdateColumn. Sets value to current timestamp using SQLDateTime.now() method.
        /// </summary>
        public void update()
        {
            this.value = now();
        }
    }
}
